#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve() {
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	int l = 0, r = n - 1;
	int count = 0;
	ll ans = 0;
	while (l <= r) {
		ll x = a[r] - count;
		if (x <= 0) {
			break;
		}
		ans += x;
		r--;

		count++;
		while (l < r && a[l] - count <= 0) {
			l++;
		}

	}
	cout << ans << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}